package com.hudson.plugin;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Projects entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "projects", catalog = "reportdb")
public class Projects implements java.io.Serializable {

    // Fields

    private Integer id;
    private Hudsons hudsons;
    private Views views;
    private String projectName;
    private String childProjects;
    private String parentProjects;
    private String type;
    private String url;
    private Set<Builds> buildses = new HashSet<Builds>(0);
    private Set<Promotions> promotionses = new HashSet<Promotions>(0);

    // Constructors

    /**
     * default constructor
     */
    public Projects() {
    }

    /**
     * full constructor
     */
    public Projects(Hudsons hudsons, Views views, String projectName,
                    String childProjects, String parentProjects, String type,
                    String url, Set<Builds> buildses, Set<Promotions> promotionses) {
        this.hudsons = hudsons;
        this.views = views;
        this.projectName = projectName;
        this.childProjects = childProjects;
        this.parentProjects = parentProjects;
        this.type = type;
        this.url = url;
        this.buildses = buildses;
        this.promotionses = promotionses;
    }

    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "hudson_id")
    public Hudsons getHudsons() {
        return this.hudsons;
    }

    public void setHudsons(Hudsons hudsons) {
        this.hudsons = hudsons;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "view_id")
    public Views getViews() {
        return this.views;
    }

    public void setViews(Views views) {
        this.views = views;
    }

    @Column(name = "project_name", length = 64)
    public String getProjectName() {
        return this.projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    @Column(name = "child_projects", length = 64)
    public String getChildProjects() {
        return this.childProjects;
    }

    public void setChildProjects(String childProjects) {
        this.childProjects = childProjects;
    }

    @Column(name = "parent_projects", length = 64)
    public String getParentProjects() {
        return this.parentProjects;
    }

    public void setParentProjects(String parentProjects) {
        this.parentProjects = parentProjects;
    }

    @Column(name = "type", length = 32)
    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Column(name = "url", length = 256)
    public String getUrl() {
        return this.url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "projects")
    public Set<Builds> getBuildses() {
        return this.buildses;
    }

    public void setBuildses(Set<Builds> buildses) {
        this.buildses = buildses;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "projects")
    public Set<Promotions> getPromotionses() {
        return this.promotionses;
    }

    public void setPromotionses(Set<Promotions> promotionses) {
        this.promotionses = promotionses;
    }

}